package com.rmy.queue.controller;


import com.rmy.common.annotation.Log;
import com.rmy.common.core.controller.BaseController;
import com.rmy.common.core.domain.AjaxResult;
import com.rmy.common.core.page.TableDataInfo;
import com.rmy.common.core.text.Convert;
import com.rmy.common.enums.BusinessType;
import com.rmy.common.utils.poi.ExcelUtil;
import com.rmy.queue.domain.QmsMainBusiness;
import com.rmy.queue.domain.QmsReportSummary;
import com.rmy.queue.service.IQmsMainBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 查询统计Controller
 *
 * @author rmy
 * @date 2022-10-20
 */
@RestController
@RequestMapping("/queue/reportlist")
public class QmsReportListController extends BaseController {

    @Autowired
    private IQmsMainBusinessService qmsMainBusinessService;

    /**
     * 查询汇总统计列表
     */
    @GetMapping("/selectSummaryList")
    public TableDataInfo selectSummaryList(QmsMainBusiness qmsMainBusiness)
    {
        startPage();
        List<QmsReportSummary> list =qmsMainBusinessService.selectSummaryList(qmsMainBusiness);
        return getDataTable(list);
    }

    /**
     * 根据机构查询列表
     */
    @GetMapping("/selectSummaryListByDept")
    public TableDataInfo selectSummaryListByDept(QmsMainBusiness qmsMainBusiness)
    {
        startPage();
        List<QmsReportSummary> list =qmsMainBusinessService.selectSummaryListByDept(qmsMainBusiness);
        return getDataTable(list);
    }
    /**
     * 根据业务查询列表
     */
    @GetMapping("/selectSummaryListByBusiness")
    public TableDataInfo selectSummaryListByBusiness(QmsMainBusiness qmsMainBusiness)
    {
        startPage();
        List<QmsReportSummary> list =qmsMainBusinessService.selectSummaryListByBusiness(qmsMainBusiness);
        return getDataTable(list);
    }

    /**
     * 导出汇总统计列表
     */
    @Log(title = "查询统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QmsMainBusiness qmsMainBusiness)
    {
        List<QmsReportSummary> list = qmsMainBusinessService.selectSummaryList(qmsMainBusiness);
        ExcelUtil<QmsReportSummary> util = new ExcelUtil<>(QmsReportSummary.class);
        util.exportExcel(response, list, "汇总统计");
    }
    /**
     * 导出汇总统计列表
     */
    @Log(title = "查询统计", businessType = BusinessType.EXPORT)
    @PostMapping("/exportByDept")
    public void exportByDept(HttpServletResponse response, QmsMainBusiness qmsMainBusiness)
    {
        List<QmsReportSummary> list = qmsMainBusinessService.selectSummaryListByDept(qmsMainBusiness);
        ExcelUtil<QmsReportSummary> util = new ExcelUtil<>(QmsReportSummary.class);
        util.exportExcel(response, list, "汇总统计");
    }
    /**
     * 导出汇总统计列表
     */
    @Log(title = "查询统计", businessType = BusinessType.EXPORT)
    @PostMapping("/exportByBusiness")
    public void exportByBusiness(HttpServletResponse response, QmsMainBusiness qmsMainBusiness)
    {
        List<QmsReportSummary> list = qmsMainBusinessService.selectSummaryListByBusiness(qmsMainBusiness);
        ExcelUtil<QmsReportSummary> util = new ExcelUtil<>(QmsReportSummary.class);
        util.exportExcel(response, list, "汇总统计");
    }

}
